package iofile;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

public class BufferedWriter_ {

    public static void main(String[] args) {
        String filePath = "";
        BufferedWriter bufferedWriter = null;

        try {
            //new FileWriter(String, true)以追加方式写入
            //new FileWriter(String)以覆盖方式写入
            bufferedWriter = new BufferedWriter(new FileWriter(filePath));
            bufferedWriter.write("asdf");
            //插入一个和系统相关的换行符
            bufferedWriter.newLine();
            bufferedWriter.write("zxcv");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            try {
                //只需要关闭外层的处理流
                bufferedWriter.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
